from models.models import Access
from service.BaseService import BaseService
from service.RoleAccessService import RoleAccessService
from config import settings
from sqlmodel import Session, select
from typing import Optional,List


class AccessService(BaseService[Access]):
    def __init__(self):
        super().__init__(Access)

    def get_access_by_id(self, access_id: str):
        statment = select(Access).where(Access.access_id == access_id)
        return self.session.exec(statment).first()

    def get_access_by_id_menu(self, access_id: str):
        statment = select(Access).where(Access.access_id == access_id and Access.is_menu == True)
        return self.session.exec(statment).first()

    def get_verify_access(self):
        statment = select(Access).where((Access.is_verify == True) & (Access.is_menu == True))
        return self.session.exec(statment).all()

    def get_parent_access(self, access_id: str):
        statment = select(Access).where(Access.parent_id == access_id)
        return self.session.exec(statment).all()







